package com.techsoul.common.core.pojo.vo;

import java.util.Date;

import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.techsoul.common.core.annotation.ExcelField;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.List;

/**
 * 用户 Vo
 *
 * @author liuen
 * @date 2020-12-04
 */
@Data
@Accessors(chain = true)
public class UserVo implements Serializable {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty("用户角色列表")
    private List<RoleVo> userRoles;
    @ApiModelProperty("consigneeId")
    private String consigneeId;

    @ApiModelProperty("companyId")
    private String companyId;
    @ApiModelProperty("用户岗位列表")
    private List<PostVo> userPosts;
    @ApiModelProperty("证件类型")
    private String ownerIdType;
    @ApiModelProperty("角色ID集合")
    private List<String> roleIds;

    @ApiModelProperty("岗位ID集合")
    private List<String> postIds;

    @ApiModelProperty("ID（系统自动产生）")
    private String id;

    @ApiModelProperty("用户编号")
    @ExcelField(title = "用户编号")
    private String userCode;

    @ApiModelProperty("用户账号")
    @ExcelField(title = "用户账号")
    private String userName;

    @ApiModelProperty("用户昵称")
    @ExcelField(title = "用户昵称")
    private String nickName;

    @ApiModelProperty("密码")
    @JSONField(serialize = false)
    private String password;

    @ApiModelProperty("组织机构id，ref sys_org")
    private String orgId;

    @ApiModelProperty("用户类型（数据字典sys_user_type）")
    private String userType;

    @ApiModelProperty("用户性别（数据字典sys_sex_type）")
    private String sex;

    @ApiModelProperty("身份证号码")
    private String idCardNo;

    @ApiModelProperty("手机号码")
    private String phone;

    @ApiModelProperty("邮箱")
    private String email;

    @ApiModelProperty("地址")
    private String address;

    @ApiModelProperty("头像")
    private String avatar;

    @ApiModelProperty("学历，数据字典sys_education_type")
    private String education;

    @ApiModelProperty("个人情况描述，自由填写，如特长、特征等")
    private String userDesc;

    @ApiModelProperty("微信openid")
    private String openid;

    @ApiModelProperty("最后登录IP")
    private String latestLoginIp;

    @ApiModelProperty("最后登录时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date latestLoginTime;

    @ApiModelProperty("所属商户ID")
    private String storeId;

    @ApiModelProperty("所属保理公司ID")
    private String baoliCompanyId;

    @ApiModelProperty("状态")
    private String status;

    @ApiModelProperty("备注")
    private String remark;

    @ApiModelProperty("是否有效（数据字典sys_yn_type，默认1-是）")
    private String isValid;

    @ApiModelProperty("创建人")
    private String createBy;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date createTime;

    @ApiModelProperty("更新人")
    private String updateBy;

    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd")
    private Date updateTime;

    @ApiModelProperty("创建人名称")
    private String createByName;

    @ApiModelProperty("更新人名称")
    private String updateByName;

    @ApiModelProperty("加密盐")
    private String salt;

    @ApiModelProperty("组织名称")
    private String orgName;
    @ApiModelProperty("企业编码")
    private String customerId;
    @ApiModelProperty("域")
    private String site;

    @ApiModelProperty("所属公司名称")
    private String companyName;
    @ApiModelProperty("供应商")
    private String supplierId;
    public boolean isAdmin() {
        return isAdmin(this.id);
    }

    public static boolean isAdmin(String userId) {
        return userId != null && "1".equals(userId);
    }

}
